;(function($) {
	$.ExcelUtil = $.ExcelUtil || {};
	$.extend($.ExcelUtil,{
		defaultConfig : {
			url : App.ctx + "/common/excel.do?method=export"
		},
		exportExcel : function(params) {
			var config = $.extend({}, $.ExcelUtil.defaultConfig, params);

			// url
			var url = config.url;
			delete config.url;
			if (url.indexOf("?") > 0) {
				url += "&random=" + Math.random();
			} else {
				url += "?random=" + Math.random();
			}
			// 方式1.对URL拼接参数(url 拼接参数，有中文时需要转换)
//			var serializePostData = "";
//			for ( var key in config.params) {
//				serializePostData += "&"+key +"="+ $.objToJSONString(config.params[key]);
//			}
			// 方式2.构建页面form 从表单提交数据
			var html = "";
			html += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
			html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
			html += "<head>";
			html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></meta>";
			html += "<title></title>";
			html += "</head>";
			html += "<body class=\"body\">";
			html += "<form id='excelExportForm' method='post' enctype='application/x-www-form-urlencoded' action='"+ url + "' style='display: none;'>";
			for ( var key in config.params) {
				html += "<textarea name='" + key + "'/>"+$.objToJSONString(config.params[key])+"</textarea>";
			}
			html += "</form><script type='text/javascript'>document.getElementById(\"excelExportForm\").submit();//window.setTimeout('window.close()',60000);</script></body></html>";
			
			//打开
			var win = window.open(App.ctx+"/pages/common/empty.jsp", "");
			win.document.write(html);
		}
	});
})(jQuery);
